{extend name='admin@main'}

{block name="button"}

{if auth("add")}

{/if}

{if auth("remove")}

{/if}

{/block}

{block name="content"}
<style type="text/css">
     .upload-image-box {
        width: 130px;
        height: 90px;
        border: 1px solid rgba(125, 125, 125, .1);
        background: url("__ROOT__/static/theme/img/404_icon.png") no-repeat center center;
        background-size: cover;
    }
    .personimg-box{
        width: 180px;
        max-height: 180px;
        border-radius: 6px;
        overflow: hidden;
        margin:0 auto;
    }
    .personimg{
        
        width: 180px;
    }
    .layui-form-item div input{width: 300px!important;}
</style>
{php}
{//var_dump($userinfo);}
{/php}
<div class="think-box-shadow" style="height: 100%">

<div class="layui-tab layui-tab-card">
  <ul class="layui-tab-title">
    <li class="layui-this">个人资料</li>
    <!-- {if $userinfo['db1']['authorize'] != 1 }
      <li>公司信息</li>
    {/if} -->

  </ul>
  <div class="layui-tab-content" >
    <div class="layui-tab-item layui-show">
<div class="margin-left-40">  
<!--   常规布局（以中型屏幕桌面为例）： -->
  <div class="layui-row">
    <div class="layui-col-md9 margin-left-40">
      <form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">

  <!--  <div class="layui-card-body padding-left-40"> -->
        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">用户名称</span></label>
            <div class="layui-input-block">
                                 {if $userinfo['db2'] == NULL}
                <input disabled value="{$userinfo['db1']['username']|default=''}" class="layui-input layui-bg-gray">
                {else/}
                <input disabled value="{$userinfo['db2']['name']|default=''}" class="layui-input layui-bg-gray">
                {/if}
            </div>
        </div>

        <div class="layui-form-item layui-col-md10 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">登录手机</span></label>
            <div class="layui-input-inline" style="width: 300px;">
                <input disabled type="tel" maxlength="11" autocomplete="off"  name="phone" value="{$userinfo['db1']['phone']|default=''}" pattern="^1[3-9][0-9]{9}$" placeholder="请输入用户联系手机" class="layui-input layui-bg-gray">

            </div>

            <div class="layui-input-inline margin-top-10">
                  <span><a  data-modal='{:url("chphone")}' ><i class="layui-icon " style="font-size: 20px; color: #1E9FFF;">&#xe642;</i>更换号码</a></span>
             </div>
        </div>

        {if $userinfo['db1']['authorize'] == 1}
        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">所属公司</span></label>
            <div class="layui-input-block">
                   <input disabled value="中山市协成科技有限公司" class="layui-input layui-bg-gray">
            </div>
        </div>

        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">所属部门</span></label>
            <div class="layui-input-block">
                  <input disabled value="技术部门" class="layui-input layui-bg-gray">
            </div>
        </div>

        {else}

        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">所属公司</span></label>
            <div class="layui-input-block">
                {if @$userinfo['db2']['company_name'] == NULL}
                
                    <input disabled value="{$userinfo.db2.company_name|default=''}" class="layui-input layui-bg-gray">
                
                   
                    <button data-open="{:url('company/company/companycenter')}?spm=m-199-200-231"style="position: absolute;top: 0;" type="button" class="layui-btn layui-btn-normal">立即公司认证</button>
                  
                
                {else/}
                <input disabled value="{$userinfo['db2']['company_name']|default=''}" class="layui-input layui-bg-gray">
                {/if}
            </div>
        </div>


        {if $userinfo.db2.dept_name}
        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">所属部门</span></label>
            <div class="layui-input-block">
                  <input disabled value="{$userinfo.db2.dept_name|default=''}" class="layui-input layui-bg-gray">
            </div>
        </div>
        {/if}
        {/if}



        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">用户类型</span></label>
            <div class="layui-input-block">
                 <input disabled value="{$authorizeinfo['title']|default=''}" class="layui-input layui-bg-gray">
            </div>
        </div>


        <!-- 会员信息 -->
<!--         {if $userinfo['db1']['authorize'] ==2 || $userinfo['db1']['authorize'] == 8}
          <div class="layui-form-item">
              <label class="relative block">
                  <span class="color-green font-w7">会员信息</span>
                  <span class="color-desc margin-left-5">Member</span>
                  <p class="margin-left-5">

                  {if @$storememberinfo}
                    {if condition="($storememberinfo.vip_level eq 0)"}
                      <span class="color-blue">访客会员</span>
                       {elseif condition="($storememberinfo.vip_level eq 1)"/}
                       <span class="color-blue">租户会员</span>
                        {elseif condition="($storememberinfo.vip_level eq 2)"/}
                        <span class="color-blue">物业会员</span>
                         {elseif condition="($storememberinfo.vip_level eq 3)"/}
                         <span class="color-blue">企业会员</span>
                         {else /}
                    {/if}
                  </br>

                  {if condition="($storememberinfo.year neq 0)"}
                      <span class="color-blue">套餐类型: {$storememberinfo.year|default=''}/年付</span>
                    {elseif condition="($storememberinfo.month neq 0)"/}
                      <span class="color-blue">套餐类型: {$storememberinfo.month|default=''}/月付</span>
                    {elseif condition="($storememberinfo.day neq 0)"/}
                      <span class="color-blue">套餐类型: {$storememberinfo.day|default=''}/日付</span>
                    {else /}
                  {/if}
                </br>
                  <span class="color-blue">续费日期:{$storememberinfo.vip_date|default=''}</span>
                    {else}
                      暂无信息
                  {/if}

                </p>
                
                

              </label>  
              <p class="help-block"></p>
          </div>
        {/if} -->
<!-- 会员信息end -->

        <div class="layui-form-item layui-col-md10 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7 font-s13">联系邮箱</span></label>
            <div class="layui-input-inline" style="width: 300px;" >
                <input disabled  name="mail" autocomplete="off" pattern="^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$" value="{$userinfo['db1']['mail']|default=''}" placeholder="请绑定邮箱" class="layui-input layui-bg-gray">

            </div>

            <div class="layui-input-inline margin-top-10">
                {if $userinfo['db1']['mail']==""}
            <span><a  data-modal='{:url("chemail")}' ><i class="layui-icon " style="font-size: 20px; color: #1E9FFF;">&#xe642;</i>绑定邮箱</a></span>

            {else}
            <span><a  data-modal='{:url("chemail")}' ><i class="layui-icon " style="font-size: 20px; color: #1E9FFF;">&#xe642;</i>更换邮箱</a></span>

            {/if}
             </div>
        </div>

        {if $userinfo['db1']['authorize'] ==2 || $userinfo['db1']['authorize'] ==3 || $userinfo['db1']['authorize'] ==1}
        <div class="layui-form-item layui-col-md5 margin-top-20">
            <label class="layui-form-label text-left"> <span class="font-w7"><!-- 添加员工账号 --></span></label>
            <div class="layui-input-block">
                <button type="button" data-open="{:url('company/department/index')}?spm=m-57-58-62" data-close data-title="添加员工" class='layui-btn layui-btn-normal'>添加公司员工</button>
            </div>
        </div>
        {/if}

        {notempty name='authorizes'}
        <div class="layui-form-item relative">
            <span class="font-w7">(后台)角色访问授权</span>
            <span class="color-desc margin-left-5">Authorization</span>
            <div class="layui-textarea">
                {if isset($vo.username) and $vo.username eq 'admin'}
                <span class="color-desc">超级用户不需要配置权限</span>
                {elseif empty($authorizes)}
                <span class="color-desc">未配置权限</span>
                {else}
                {foreach $authorizes as $authorize}
                <label class="think-checkbox layui-unselect">
                    {if in_array($authorize.id, $vo.authorize)}
                    <input type="checkbox" checked name="authorize[]" value="{$authorize.id}" lay-ignore> {$authorize.title}
                    {else}
                    <input type="checkbox" name="authorize[]" value="{$authorize.id}" lay-ignore> {$authorize.title}
                    {/if}
                </label>
                {/foreach}
                {/if}
            </div>
        </div>

        <div class="layui-form-item relative">
            <span class="font-w7">(前台)角色身份授权</span>
            <span class="color-desc margin-left-5">RoleIdentity</span>
            <div class="layui-textarea">
                {if isset($vo.username) and $vo.username eq 'admin'}
                <span class="color-desc">超级用户不需要配置权限</span>
                {elseif empty($authorizes)}
                <span class="color-desc">未配置权限</span>
                {else}
                {foreach $role as $roleidset}
                <label class="think-radio layui-unselect">
                    {if in_array($userinfo['db1']['roleid'],$roleidset)}
                    <input type="radio" checked name="roleid" value="{$roleidset.id}" title="{$roleidset.name}">{$roleidset.name}
                    {else}
                    <input type="radio" name="roleid" value="{$roleidset.id}" title="{$roleidset.name}"> {$roleidset.name}
                    {/if}

                </label>
                {/foreach}
                {/if}
            </div>
        </div>

        {/notempty}

        {if $userinfo['db1']['authorize'] ==0 || $userinfo['db1']['authorize'] == 1 }
<!--         <div class="layui-form-item">
            <label class="relative block">
                <span class="font-w7">用户身份描述</span>
                <span class="color-desc margin-left-5">Description</span>
                <textarea placeholder="请输入用户身份描述" class="layui-textarea" name="desc">{$vo.desc|default=""}</textarea>
            </label>
        </div> -->
  
    {/if}
    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

<!--     <div class="layui-form-item ">
        <div class="layui-input-block">
        <button class="layui-btn" type='submit'>保存数据</button>
         </div>
    </div> -->
 <!--  </div> -->
</form>
    </div>
    <div class="layui-col-md2">
        <div class="layui-col-md12 margin-top-40">
                <div class="personimg-box">
                  {if $userinfo['db2']['personimg']}


                    {php}
                       {
                       //var_dump($userinfo['db2']['personimg']);
                      //路径1
                        if (strstr($userinfo['db2']['personimg'],'http://devs.zsicp.com') || strstr($userinfo['db2']['personimg'],'http://pc.zsicp.com')){
                        
                          echo  "<img data-tips-image class='personimg' src=".$userinfo['db2']['personimg'].">";

                        }else{
                          if($userinfo['db2']['personimg'] != ""){
                           echo  "<img data-tips-image class='personimg' src=http://devs.zsicp.com/public/upload/person/".$userinfo['db2']['personimg'].">";
                          }else{
                            echo "<img data-tips-image src='http://devs.zsicp.com/public/upload/person/normal/userlogo.png'>";

                          }
                        }
                    
                        }
                    {/php}
          
                
                  {/if}
                </div>
        </div>

     <!--  你的内容 3/12 -->
    </div>
  </div>

    </div>

    <div class="layui-tab-item">

  <h3 class="margin-left-40">更新公司信息</h3>

<div class="layui-card-body padding-left-40">

    {if $userinfo['db1']['authorize'] == 2 || $userinfo['db1']['authorize'] == 8}

        {if @$companyinfo}
            {php}
               {
            
                if (strstr($companyinfo['imgurl'],'http://pc.zsicp.com')){
                    echo  "<img style='width: 120px' data-tips-image src=".$companyinfo['imgurl'].">";
                }else{
                    echo "<img style='width: 120px' data-tips-image src="."http://devs.zsicp.com/public/upload/business_license/".$companyinfo['imgurl'].">";   
                }
            
                }
               {/php}
            {else}
              <p>公司信息未找到.</p>
        {/if}

    {/if}
</div>

<form id="companycard-form" action="{:url('personal/upload')}" onsubmit="return false;"  method="post" enctype="multipart/form-data">
  <div class="layui-card-body padding-left-40">
     <div class="layui-form-item">
    <label class="layui-form-label">企业名称</label>
    <div class="layui-input-block">
      {if @$companyinfo}
        <input readonly type="text" name="title" required  lay-verify="required" value="{$companyinfo['name']|default=''}" autocomplete="off" class="layui-input">
      {else}
        <input readonly type="text" name="title" required  lay-verify="required"  autocomplete="off" class="layui-input">
      {/if}
      
    </div>
  </div>
       <div class="layui-form-item">
    <label class="layui-form-label">公司负责人</label>
    <div class="layui-input-block">
              {if @$companyinfo}
                <input readonly type="text" name="corporation" required  lay-verify="required"  value="{$companyinfo['corporation']|default=''}" autocomplete="off" class="layui-input">
              {else}
                <input readonly type="text" name="corporation" required  lay-verify="required" autocomplete="off" class="layui-input">
              {/if}
      
    </div>
  </div>
     <div class="layui-form-item">
    <label class="layui-form-label">工商营业执照注册号/统一社会信用代码</label>
    <div class="layui-input-block">
              {if @$companyinfo}
                <input readonly type="text" name="code"   lay-verify="required"  value="{$companyinfo['code']|default=''}" autocomplete="off" class="layui-input">
              {else}
                <input readonly type="text" name="code"   lay-verify="required" autocomplete="off" class="layui-input">
              {/if}
      
    </div>
  </div>

       <div class="layui-form-item">
    <label class="layui-form-label">公司地址</label>
    <div class="layui-input-block">
              {if @$companyinfo}
                <input readonly type="text" name="address" required  lay-verify="required"  value="{$companyinfo['address']|default=''}" autocomplete="off" class="layui-input">
              {else}
                <input readonly type="text" name="address" required  lay-verify="required"autocomplete="off" class="layui-input">
              {/if}
      
    </div>
  </div>

<!--          <div class="layui-form-item">
    <label class="layui-form-label">工商营业执照有效期截止时间</label>
   <div class="layui-input-inline margin-right-0" style="width:164px">
       <input type="text" data-date-input="date" name="entry_date" value='{$vo.entry_date|default=""}' placeholder="请输入入职日期" class="layui-input">
   </div>
  </div> -->
        <div class="layui-form-item">
            <label class="layui-form-label label-required">公司营业执照</label>

            <div class="layui-input-block">

                <div class="layui-textarea padding-bottom-10" style="min-height:auto">
                  
                <div id="NewsEditor" class="layui-clear nowrap padding-bottom-30">
                <span class="">(营业执照-缩略图)</span>
                {notempty name='vo.imgurl'}
               {php}
               {
            
                if (strstr($vo['imgurl'],'http://pc.zsicp.com')){
                    echo  "<img name="."old_imgurl"." data-tips-image style="."max-width:120px;height:60px;vertical-align:top"." src=".$vo['imgurl']." class="."margin-right-5".">";

                  echo "<input data-auto-none value=".$vo['imgurl']." type="."hidden"." name="."old_imgurl".">";
                }else{
 

                    echo  "<img name="."old_imgurl"." data-tips-image style="."max-width:120px;height:60px;vertical-align:top"." src="."http://devs.zsicp.com/public/upload/business_license/".$vo['imgurl']." class="."margin-right-5".">";

                    echo "<input data-auto-none value=".$vo['imgurl']." type="."hidden"." name="."old_imgurl".">";
                }
            
                }
               {/php}



    <label class="layui-form-label">使用原有营业执照</label>
    <div class="layui-input-block" >
      <input lay-filter="ye_switch" type="checkbox" name="ye_switch" lay-skin="switch">
    </div>
                {/notempty}
                <div class="layui-form-item label-required-prev upload_yye">

                    <div class="layui-clear">
  
                        <div class="upload-image-box pull-left transition" data-tips-image="{{item.local_url}}" style="{{item.style}}">
                            <input ng-model="item.local_url" data-auto-none value="{{item.local_url}}" type="hidden" name="local_url">
                        </div>
                        <div class="pull-left padding-top-15 padding-left-15">
                           
                            <button type="button" data-title="上传营业执照" data-file="btn" data-type="jpg,png,jpeg" data-field="local_url" class="layui-btn layui-btn-sm layui-btn-primary">
                            {if @$vo.id}
                            重新上传营业执照
                            {else}
                            上传营业执照
                            {/if}
                        </button>
                            <br>

                        </div>
                    </div>
                    <p class="color-desc">封面大图片建议尺寸 900像素 * 500像素</p>
                </div>
                </div>
                </div>
            </div>
        </div>

<!--   {if @$companyinfo}
      <div class="layui-form-item"> 
        <label class="layui-form-label">重新上传(营业执照)</label>
        <input type="file" class="imgurl" name="imgurl" id="imgurl">
      </div> 
  {else}
      <div class="layui-form-item"> 
        <label class="layui-form-label">上传营业执照</label>
        <input type="file" class="imgurl" name="imgurl" id="imgurl">
      </div> 
  {/if}
 -->
    <input type='hidden' value='update' name='companycardtype'>
     <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn companycardsub-btn" lay-submit lay-filter="formDemo">立即提交</button>
     
    </div>
  </div>


</div>
</form>




</div>
<!--     <div class="layui-tab-item">4</div>
    <div class="layui-tab-item">5</div>
    <div class="layui-tab-item">6</div> -->
  </div>
</div>






</div>



<script type="text/javascript">
      require(['angular', 'ckeditor'], function () {

        var $form = $('form[name="news"]');
        var $vali = $form.vali().data('validate');
        // var editor = window.createEditor('[name="content"]');

        var app = angular.module("NewsEditor", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);


        form.on('switch(ye_switch)', function(data){
            console.log(data.elem); //得到checkbox原始DOM对象
        // 　　console.log(data.elem.checked); //开关是否开启，true或者false
        // 　　console.log(data.value); //开关value值，也可以通过data.elem.value得到
        // 　　console.log(data.othis); //得到美化后的DOM对象
            if(data.elem.checked){

                $('.upload_yye').css({'display':'none'});
             }else{
                $('.upload_yye').css({'display':'block'});
                }
        });
        $("input[name='type']").change(function(data){
           var radioval = $('input[name="type"]:checked').val();
           console.log(radioval)
           if(radioval == 2 || radioval == 3 ){
                $('#ch-company-type').css({'display':'none'});
           }else{
                $('#ch-company-type').css({'display':'block'});
           }

        })
        /**营业执照提交更新**/
        $('.companycardsub-btn').on('click',function(){
          var data = $("#companycard-form").serializeArray();
          console.log(data)
        postData = {};
        $(data).each(function(i) {
            
            postData[this.name]= this.value;

          });
          if(postData["local_url"]==""){
            postData["local_url"] =  '{@$companyinfo["imgurl"]}'
          }
          $.post("{:url('personal/upload')}",postData, function(result) {
                //result = JSON.parse(result)
                console.log(result)
                if (result.code == 1) {
                    //成功
                    return $.msg.success(result.info);
                } else if (result.code == 0) {
                    // 失败
                    return $.msg.error(result.info);
                }
                    }, "JSON");

        })

        function callback($rootScope) {
            $rootScope.list = [];
            $rootScope.item = {};

            $rootScope.setItemValue = function (name, value) {
              console.log("回调")
              console.log(name)
              console.log(value)
              console.log($rootScope.item.local_url)
                $rootScope.item[name] = value;
                $rootScope.item.style = "background-image:url('" + $rootScope.item.local_url + "')";

                if(eval('{@$companyinfo}')){
                    postdata = {
                        'local_url':value,
                        'type':'update'
                        };
                    }else{
                    postdata = {
                        'local_url':value,
                        };
                    }
              $.post("{:url('personal/upload')}",postdata , function(result) {
                result = JSON.parse(result)
                console.log(result)
                if (result.code == 200) {
                    //成功
                    $('input[name="title"]').val(result.data.name)
                    $('input[name="code"]').val(result.data.code)
                    $('input[name="address"]').val(result.data.address)
                    $('input[name="corporation"]').val(result.data.corporation)
                    return $.msg.success(result.message);
                } else if (result.code == 400) {
                    // 失败
                    return $.msg.error(result.message);
                }
                    }, "JSON");
                  };


            $('[name="local_url"]').on('change', function () {
                var value = this.value;
                $rootScope.$apply(function () {
                    $rootScope.setItemValue('local_url', value);
                });
            });
        }
    });
</script>
{/block}
